package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dao.DishPageDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {

    List<Dish> list(Dish dish);

    @Select("select count(*) from dish where category_id = #{id} and status = 1")
    Integer count(Integer id);

    Page<DishVo> page(DishPageDTO dishPageDTO);

    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    Dish getById(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);


    @Delete("delete from dish where id = #{id}")
    void deleteById(Long id);

    @Select("select count(*) from dish where status = #{status}")
    Integer countDish(Integer status);
}
